/**
 * @file Define Web application default handlers
 * 
 * @author Steve Gao<gaofu@parllay.com>
 */

const WebBaseController = require('./web-base-controller');
const SystemServices = require('../../constants').SystemServices;

/**
 * The administration controller class
 * 
 * @class DefaultController
 * @extends {WebBaseController}
 */
class DefaultController extends WebBaseController {

    get leadBarService() {
        if (!this._leadBarService) {
            this._leadBarService = this.getSystemService(SystemServices.LEADBAR_SERVICE);
        }

        return this._leadBarService;
    }

    get trackingService() {
        if (!this._trackingService) {
            this._trackingService = this.getSystemService(SystemServices.TRACKING_SERVICE);
        }

        return this._trackingService;
    }

    get shortUrlService() {
        if (!this._shortUrlService) {
            this._shortUrlService = this.getSystemService(SystemServices.SHORTURL_SERVICE);
        }

        return this._shortUrlService;
    }


    get qiniuService() {
        if (!this._qiniuService) {
            this._qiniuService = this.getSystemService(SystemServices.QINIU_SERVICE);
        }

        return this._qiniuService;
    }

    get retailService() {
        if (!this._retailService) {
            this._retailService = this.getSystemService(SystemServices.RETAIL_SERVICE);
        }

        return this._retailService;
    }


    get handlersPath() {
        return 'default';
    }

    get name() {
        return "DefaultController";
    }

   
    getUserProfile(userId, parentCallback) {
        this.retailService.getUserProfile(userId, (result) => {
            parentCallback(result);
        });
    }

    
    /**
     * 获取会员客户列表
     * @param {*} params 
     * @param {*} parentCallback 
     */
    getGoodsList(params, parentCallback) {
        this.retailService.getGoodsList(params, (result) => {
            parentCallback(result);
        });
    }

    getAcList(params, parentCallback) {
        this.retailService.getAcList(params, (result) => {
            parentCallback(result);
        });
    }

    /**
     *  快速录入VIP
     * @param {*} params 
     * @param {*} parentCallback 
     */
    createNewContact(params, parentCallback) {
        this.retailService.createNewContact(params, (result) => {
            parentCallback(result);
        })
    }

    /**
     * 查询进店顾客
     */
    getVisitList(params, parentCallback) {
        this.retailService.getVisitList(params, (result) => {
            parentCallback(result);
        })
    }

    /**
     * 
     * 保存用户修改的个人信息
     * @param {*} params 
     * @param {*} parentCallback 
     */
    saveUserInfo(params, parentCallback) {
        this.retailService.saveUserInfo(params, (result) => {
            parentCallback(result);
        })
    }

    /**
     * 
     * 更改用户头像
     * @param {*} params 
     * @param {*} parentCallback 
     */
    changeUserAvatar(params, parentCallback) {
        this.retailService.changeUserAvatar(params, (result) => {
            parentCallback(result);
        })
    }

    /**
     * 
     * 验证登录用户
     * @param {*} userName 
     * @param {*} password 
     * @param {*} parentCallback 
     */
    verifyUser(userName, password, parentCallback) {
        this.retailService.verifyUser(userName, password, (result) => {
            parentCallback(result);
        })
    }

    /**
     * 
     * 获取客户的订单列表信息
     * @param {*} params 
     * @param {*} parentCallback 
     */
    getAssociatorOrder(params, parentCallback) {
        this.retailService.getAssociatorOrder(params, (result) => {
            parentCallback(result);
        })
    }

    /**
     * 
     * 得到会员的事件
     * @param {*} params 
     * @param {*} parentCallback 
     */
    getAssociatorEvents(params, parentCallback) {
        this.retailService.getAssociatorEvents(params, (result) => {
            parentCallback(result);
        });
    }

    /**
     * 
     * 得到所有订单列表
     * @param {*} params 
     * @param {*} parentCallback 
     */
    getAssociatorLinkOrder(params, parentCallback) {
        this.retailService.getAssociatorLinkOrder(params, (result) => {
            parentCallback(result);
        });
    }

    /**
     * 
     * 关联订单给用户
     * @param {*} params 
     * @param {*} parentCallback 
     */
    setUserOrder(params, parentCallback) {
        this.retailService.setUserOrder(params, (result) => {
            parentCallback(result);
        });
    }


    /**
     * 
     * 获取所有门店数据
     * @param {*} parentCallback 
     */
    getAllTeams(parentCallback) {
        this.retailService.getAllTeams((result) => {
            parentCallback(result);
        })
    }

    /**
     * 
     * 获取所有店员列表数据
     * @param {*} params 
     * @param {*} parentCallback 
     */
    getAllUsers(params, parentCallback) {
        this.retailService.getAllUsers(params, (result) => {
            parentCallback(result);
        })
    }

    /**
     * 
     * 增加店员
     * @param {*} params 
     * @param {*} parentCallback 
     */
    operateUser(params, parentCallback) {
        this.retailService.operateUser(params, (result) => {
            parentCallback(result);
        })
    }

    operateTasks(params, parentCallback) {
        this.retailService.operateTasks(params, (result) => {
            parentCallback(result);
        })
    }
    /**
     * 
     * 增加商品
     * @param {*} params 
     * @param {*} parentCallback 
     */
    operateGoods(params, parentCallback) {
        this.retailService.operateGoods(params, (result) => {
            parentCallback(result);
        })
    }
    /**
     * 
     * 删除商品
     * @param {*} params 
     * @param {*} parentCallback 
     */
    DeleteGoods(params, parentCallback) {
        this.retailService.DeleteGoods(params, (result) => {
            parentCallback(result);
        })
    }
    /**
     * 
     * 七牛
     * @param {*} params 
     * @param {*} parentCallback 
     */
    operateQiniu(params, parentCallback) {
        this.retailService.operateQiniu(params, (result) => {
            parentCallback(result);
        })
    }
    /**
     * 
     * 根据条件筛选不同的任务
     * @param {*} params 
     * @param {*} parentCallback 
     */
    getTasks(params, parentCallback) {
        this.retailService.getTasks(params, (result) => {
            parentCallback(result);
        })
    }

    /**
     * 
     * 设置页的搜索店员和门店接口
     * @param {*} params 
     * @param {*} parentCallback 
     */
    commonSearch(params, parentCallback) {
        this.retailService.commonSearch(params, (result) => {
            parentCallback(result);
        })
    }

    /**
     * 
     * 客户、店员、订单、任务组搜索
     * @param {*} params 
     * @param {*} parentCallback 
     */
    tasksCommonSearch(params, parentCallback) {
        this.retailService.tasksCommonSearch(params, (result) => {
            parentCallback(result);
        })
    }



    createTeam(params, parentCallback) {
        this.retailService.createTeam(params, (result) => {
            parentCallback(result);
        })
    }

    createDevice(params, parentCallback) {
        this.retailService.createDevice(params, (result) => {
            parentCallback(result);
        })
    }

    taskGroupOperation(params, parentCallback) {
        this.retailService.taskGroupOperation(params, (result) => {
            parentCallback(result);
        })
    }

    addTaskGroup(params, parentCallback) {
        this.retailService.addTaskGroup(params, (result) => {
            parentCallback(result);
        })
    }

    addGoodsGroup(params, parentCallback) {
        this.retailService.addGoodsGroup(params, (result) => {
            parentCallback(result);
        })
    }

    getTrafficData(params, parentCallback) {
        this.retailService.getTrafficData(params, (result) => {
            parentCallback(result);
        })
    }

    getOccupyData(params, parentCallback) {
        this.retailService.getOccupyData(params, (result) => {
            parentCallback(result);
        })
    }

    updateUserProfile(userInfo, parentCallback) {
        this.retailService.updateUserProfile(userInfo, (result) => {
            parentCallback(result);
        });
    }

    getSalesData(params, parentCallback) {
        this.retailService.getSalesData(params, (result) => {
            parentCallback(result);
        })
    }

    downloadDashboard(params, parentCallback) {
        this.retailService.getOccupyData(params, (result) => {
            parentCallback(result);
        })
    }


}

exports.DefaultController = DefaultController;